package com.fanyu.test.personal;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

import org.springframework.util.DigestUtils;

import com.fanyu.framework.utils.HttpClients4;

/**
 * 再次回调检测信息
 */

public class CallBack {
    public static void main(String[] args) {
        // 请求参数
        String key = "********"; // 由维普提供的key
        String userid = "***"; // 由维普提供的userid
        String customparameter = "****"; // customparameter 是请求检测时传入的唯一标识

        // 组装请求参数
        Map<String, Object> param = new HashMap<>();
        param.put("userid", userid);
        param.put("customparameter", customparameter);
        String strParams = userid + customparameter + key; // sign组装规则
        String sign = DigestUtils.md5DigestAsHex(strParams.getBytes(StandardCharsets.UTF_8)).toLowerCase();
        param.put("sign", sign);

        // 发送请求
        HttpClients4 clients4 = new HttpClients4();

        // 回调地址
        String callbackUrl = "***";
        HttpClients4.HttpClientResult hcr = clients4.post(callbackUrl, param);

    }
}
